﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>样版信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/layui/layui.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <link href="~/Content/Scripts/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <span style="margin-top:15px;margin-left:15px">
        <xblock>
     
            <button class="layui-btn" onclick="closeWin()"><i class="layui-icon">&#x1006;</i>取消</button>
        </xblock>
    </span>

    <div style="margin: 20px; border: 1px solid #dbdbdb;padding:15px">
        <form id="AddForm" class="layui-form layui-col-space5">

            <div class="layui-form-item">
                <label class="layui-form-label">
                    样版编码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="yCode" name="yCode" autocomplete="off" class="layui-input" readonly />
                    <input type="hidden" name="id" id="id" />
                </div>
                <label class="layui-form-label">
                    样板名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="yName" name="yName" autocomplete="off" class="layui-input">
                    <input type="hidden" name="typeCode" id="typeCode" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    存放位置
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="weizhi" name="weizhi" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">
                    数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="shuliang" name="shuliang" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label for="desc" class="layui-form-label">备注说明</label>
                <div class="layui-input-block">
                    <textarea placeholder="备注说明" id="memo" name="memo" class="layui-textarea"></textarea>
                </div>
            </div>
        </form>

        <div class="layui-table-main" id="layui-table-main">
            <table class="layui-hide" id="list" lay-filter="list"></table>
        </div>
        <div class="layui-table-main" id="layui-table-main-r">
            <table class="layui-hide" id="rlist" lay-filter="rlist"></table>
        </div>
    </div>
</body>
</html>
<script type="text/html" id="barDemo">
    <a title="点击删除" href="javascript:;" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>
<script type="text/javascript">
    var typeCode = "";
    $(function () {
        dicData("bgt", "bgt");
        var dataId = getUrlVariable("dataId");
        typeCode = getUrlVariable("type");
        if (dataId != "0") {
            $("input[ name='id']").val(dataId);
            loadData(dataId);
        } else {
            $("input[ name='yCode']").val(dateTimeStr);
            $("input[ name='typeCode']").val(typeCode);
        }

    });
    /**
    加载数据信息
    **/
    function loadData(dataId) {
        $.ajax({
            url: "../Basis/UpdateTemplate",
            type: "post",
            data: { dataId: dataId },
            success: function (data) {
                if (data.Result) {
                    $.each(data.Data[0], function (name, value) {
                        if (name == "memo") {
                            $("#memo").val(value);
                        } else {
                            $("input[ name='" + name + "']").val(value);
                        }
                    });
                    loadProduct();
                    loadRecords();
                }
            }
        });

    }
    /**
    加载样版存货
    **/
    function loadProduct() {
        layui.use('table', function () {
            var yCode = $("input[ name='yCode']").val();
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
                    , { field: 'id', title: 'id', width: 90 }
                    , { field: 'proCode', title: '存货编码', width: 130 }
                    , { field: 'proName', title: '存货名称', width: 130 }
                    , { field: 'spec', title: '规格', width: 120 }
                    , { field: 'createtime', title: '创建时间', width: 150 }

            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
            }
            , url: '../Basis/GetDataList?condition=' + yCode + "&dataType=ypr" //数据接口
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , limits: [20, 35, 50]
            , limit: 20 //每页默认显示的数量
            });
            //监听行工具事件
            table.on('tool(list)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent == 'del') {

                    delYangBanProduct(data.id);
                }
            });
        });
    }
    /**
    加载样版记录
    **/
    function loadRecords() {
        layui.use('table', function () {
            var yCode = $("input[ name='yCode']").val();
            var table = layui.table;
            table.render({
                elem: '#rlist'
            , cols: [[ //标题栏
                    , { field: 'id', title: 'id', width: 90 }
                    , { field: 'doTypeName', title: '操作类型', width: 120 }
                    , { field: 'userName', title: '人员', width: 130 }
                    , { field: 'createtime', title: '创建时间', width: 150 }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
            }
            , url: '../Basis/GetDataList?condition=' + yCode + "&dataType=yri" //数据接口
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , limits: [20, 35, 50]
            , limit: 20 //每页默认显示的数量
            });
            //监听行工具事件
        
        });
    }
  
</script>